package com.lzh.prometheus.config.exceptionnotice;

import com.lzh.prometheus.aop.ExceptionNoticeAop;
import com.lzh.prometheus.config.annos.ConditionalOnExceptionNotice;
import com.lzh.prometheus.exceptionhandle.ExceptionHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhehen.lu
 * @date 2025/8/15 9:54
 */
@Configuration
@ConditionalOnExceptionNotice
@ConditionalOnProperty(name = "prometheus.exceptionnotice.listen-type", havingValue = "common", matchIfMissing = true)
public class ExceptionNoticeCommonTypeConfig {
    private final Log logger = LogFactory.getLog(ExceptionNoticeCommonTypeConfig.class);

    @Bean
    @ConditionalOnMissingBean
    public ExceptionNoticeAop exceptionNoticeAop(ExceptionHandler exceptionHandler) {
        logger.debug("创建异常监听切面");
        ExceptionNoticeAop aop = new ExceptionNoticeAop(exceptionHandler);
        return aop;
    }
}
